package com.witsight.cassandra.model;

import java.io.Serializable;

import org.springframework.data.annotation.Transient;

import com.witsight.platform.model.BaseObject;
import com.witsight.platform.util.lang.ObjectUtil;

/**   
 * 说明：Cassandra数据库实体继承此抽象对象
 * @Title: BaseEntity.java 
 * @Package com.witsight.cassandra.model 
 * @See: {@link BaseObject}
 * Copyright: Copyright (c) 2017
 * Company:sany huax witsight team by product
 * @author: penght  
 * @date: 2017年9月21日 上午11:38:28 
 * @version: V1.0
 *
 */

public abstract class BaseEntity<K extends Serializable> extends BaseObject<K>{
	private static final long serialVersionUID = 3706215224303865616L;
	// 是否是新建
	@Transient
	private boolean isNew = false;
	
	public void setIsNew( boolean isNew) {
		this.isNew = isNew;
	}
	
	@Override
	public boolean isNew() {		// true 表示保存 false 表示更新
		if (this.isNew) {
			return this.isNew;
		}
		return ObjectUtil.isEmpty(this.getId());
	}
}
